home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / util / cli / cliutils_mra.lha / Sources / Device.a < prev    next >
Encoding:
Text File  |  1999-02-22  |  4.6 KB  |  238 lines

  1. **************
  2. ** Device.a **
  3. **************
  4.  
  5. ; $VER: Device.a  v1.0  by Mauro Panigada (based on Roberto Larcher's C program)
  6. ;
  7. ; Reduced and rewritten into assembly by Mauro Panigada from
  8. ; C source code by Roberto Larcher in:
  9. ; Commodore Gazette, Nov 1991, VI, n. 5, p. 18
  10. ;
  11. ; FREEWARE
  12. ;
  13. ; (1996-06-12) Ha qualche bug di troppo, decisamente da rivedere.
  14. ; device df0: [quando df0: non c'e` come disco]
  15. ; **** fixed **** (era a6 che non aveva dos ma exec!)
  16. ; >>>>>>> id_InUse  da` valori sballati (o sbaglio a leggerlo!) NO:
  17. ; >>>>>>> infatti la doc dice LONG! Boooh!
  18. ;
  19.  
  20.  
  21.         incdir    "dh0:progr/assem/include/"
  22.         include    "exec/types.i"
  23.         include    "exec/libraries.i"
  24.         include    "exec/exec_lib.i"
  25.         include    "exec/memory.i"
  26.         include    "dos/filehandler.i"
  27.         include    "dos/dos.i"
  28.         include    "dos/dosextens.i"
  29.         include    "dos/dos_lib.i"
  30.         include    "dos/dosasl.i"
  31.  
  32.  
  33.     STRUCTURE MUDevInfo,0
  34.         LONG    _dosbase
  35.         LONG    _readarg
  36.         LONG    _array
  37.         LONG    _devport
  38.         LONG    _myport
  39.         LONG    _packet
  40.         STRUCT    _infodata,id_SIZEOF
  41.         STRUCT    _msg,MN_SIZE
  42.         STRUCT    _argv,11*4
  43.         LABEL    MUDev_SIZEOF
  44.  
  45.  
  46.         SECTION    MUDevInfoCODE,CODE
  47.  
  48.         bra.s    main
  49.  
  50.         dc.b    "$VER: Device v1.0 by MU (based on Roberto"
  51.         dc.b    " Larcher's C program",0
  52.  
  53. main        lea    mustores,a5
  54.         move.l    4.w,a6
  55.         lea    dosname(pc),a1
  56.         moveq    #37,d0
  57.         jsr    _LVOOpenLibrary(a6)
  58.         move.l    d0,_dosbase(a5)
  59.         bne.s    m_ok
  60.         rts
  61.  
  62. m_ok        move.l    d0,a6
  63.         lea    template(pc),a0
  64.         move.l    a0,d1
  65.         lea    _array(a5),a4
  66.         move.l    a4,d2
  67.         moveq    #0,d3
  68.         jsr    _LVOReadArgs(a6)
  69.         move.l    d0,_readarg(a5)
  70.         beq    m_noarg
  71.  
  72.         move.l    4.w,a6
  73.         jsr    _LVOCreateMsgPort(a6)
  74.         move.l    d0,_myport(a5)
  75.         beq    exit
  76.  
  77.         move.l    (a4),d1
  78.         move.l    _dosbase(a5),a6
  79.         jsr    _LVODeviceProc(a6)
  80.         move.l    d0,_devport(a5)
  81.         beq    exit
  82.  
  83.         moveq    #0,d2
  84.         move.l    #DOS_STDPKT,d1
  85.         jsr    _LVOAllocDosObject(a6)
  86.         move.l    d0,_packet(a5)
  87.         beq    exit
  88.  
  89.         lea    _msg(a5),a3
  90.         move.b    #NT_MESSAGE,LN_TYPE(a3)
  91.         move.l    d0,LN_NAME(a3)
  92.         move.l    _myport(a5),MN_REPLYPORT(a3)
  93.         move.w    #MN_SIZE,MN_LENGTH(a3)
  94.         move.l    d0,a2
  95.         move.l    a3,dp_Link(a2)
  96.         move.l    _myport(a5),dp_Port(a2)
  97.         move.l    #ACTION_DISK_INFO,dp_Type(a2)
  98.         lea    _infodata(a5),a4
  99.         move.l    a4,d0
  100.         lsr.l    #2,d0
  101.         move.l    d0,dp_Arg1(a2)
  102.  
  103.         move.l    4.w,a6
  104.         move.l    _devport(a5),a0
  105.         move.l    a3,a1
  106.         jsr    _LVOPutMsg(a6)
  107.         move.l    _myport(a5),a0
  108.         jsr    _LVOWaitPort(a6)
  109.         move.l    a3,a1        ;??????
  110.         jsr    _LVORemove(a6)
  111.  
  112.         move.l    id_DiskType(a4),d0
  113.         cmp.l    #ID_NO_DISK_PRESENT,d0
  114.         beq.s    nodisk
  115.         cmp.l    #ID_UNREADABLE_DISK,d0
  116.         beq.s    noreadable
  117.         cmp.l    #ID_NOT_REALLY_DOS,d0
  118.         beq.s    nopdos
  119.         cmp.l    #ID_FFS_DISK,d0
  120.         beq.s    ffsdisk
  121.         cmp.l    #ID_DOS_DISK,d0
  122.         beq.s    dosdisk
  123.  
  124.         lea    bo(pc),a0
  125. putm        move.l    a0,d1
  126.         move.l    _dosbase(a5),a6
  127.         jsr    _LVOPutStr(a6)
  128.         bra    exit
  129.  
  130. nodisk        lea    nodiskm(pc),a0
  131.         bra.s    putm
  132.  
  133. noreadable    lea    noreadm(pc),a0
  134.         bra.s    putm
  135.  
  136. nopdos        lea    nopdosm(pc),a0
  137.         bra.s    putm
  138.  
  139. ffsdisk        lea    ffs(pc),a0
  140.         move.l    a0,_argv+4(a5)
  141.         bra.s    doinfo
  142.  
  143. dosdisk        lea    dos(pc),a0
  144.         move.l    a0,_argv+4(a5)
  145.  
  146. doinfo        lea    mix(pc),a0
  147.         move.l    a0,d1
  148.         lea    _argv(a5),a0
  149.         move.l    a0,d2
  150.         move.l    _array(a5),a1
  151.         move.l    a1,(a0)
  152.         move.l    id_NumSoftErrors(a4),8(a0)
  153.         move.l    id_UnitNumber(a4),12(a0)
  154.         move.l    id_DiskState(a4),d0
  155.         sub.l    #80,d0
  156.         lsl.l    #2,d0
  157.         lea    millo(pc),a1
  158.         move.l    (a1,d0),16(a0)
  159.         move.l    id_NumBlocks(a4),20(a0)
  160.         move.l    id_NumBlocksUsed(a4),24(a0)
  161.         move.l    id_BytesPerBlock(a4),28(a0)
  162.         move.l    20(a0),d3
  163.         move.l    24(a0),d4
  164.         sub.l    d4,d3
  165.         move.l    d3,32(a0)
  166.         move.l    id_InUse(a4),36(a0)
  167.         move.l    _dosbase(a5),a6
  168.         jsr    _LVOVPrintf(a6)
  169.  
  170. exit        move.l    _readarg(a5),d1
  171.         move.l    _dosbase(a5),a6
  172.         jsr    _LVOFreeArgs(a6)
  173.         bra.s    exit0
  174. m_noarg        lea    nom(pc),a0
  175.         move.l    a0,d1
  176.         jsr    _LVOPutStr(a6)
  177. exit0        move.l    _myport(a5),d0
  178.         beq.s    noport0
  179.         move.l    d0,a0
  180.         move.l    4.w,a6
  181.         jsr    _LVODeleteMsgPort(a6)
  182. noport0        move.l    _dosbase(a5),a6
  183.         move.l    _packet(a5),d1
  184.         beq.s    nopkt
  185.         jsr    _LVOFreeDosObject(a6)
  186. nopkt        move.l    _dosbase(a5),a1
  187.         move.l    4.w,a6
  188.         jsr    _LVOCloseLibrary(a6)
  189.         rts
  190.  
  191.  
  192. dosname        dc.b    "dos.library",0
  193.         even
  194. nom        dc.b    "Forgotten argument!",10,0
  195.         even
  196. template    dc.b    "DEVICE/A",0
  197.         even
  198. bo        dc.b    "UNKNOW TYPE!",10,0
  199.         even
  200. nodiskm        dc.b    "No disk present!",10,0
  201.         even
  202. noreadm        dc.b    "Unreadable disk!",10,0
  203.         even
  204. nopdosm        dc.b    "Not really dos!",10,0
  205.         even
  206. ffs        dc.b    "FFS",0
  207. dos        dc.b    "DOS",0
  208.  
  209. mix        dc.b    10,"Information on: %s",10,10
  210.         dc.b    "Disk type: %s",10
  211.         dc.b    "Software errors: %ld",10
  212.         dc.b    "Unit: %ld",10
  213.         dc.b    "Disk state: %s",10
  214.         dc.b    "Number of blocks: %ld",10
  215.         dc.b    "Number of used blocks: %ld",10
  216.         dc.b    "Bytes per blocks: %ld",10
  217.         dc.b    "Free blocks: %ld",10
  218.         dc.b    "Disk in use (1=TRUE, 0=FALSE): %ld",10,10,0
  219.         even
  220.  
  221. millo        dc.l    m0,m1,m2
  222.  
  223. m0        dc.b    "Write protect",0
  224.         even
  225. m1        dc.b    "Validating",0
  226.         even
  227. m2        dc.b    "It exists and is writable",0
  228.         even
  229.  
  230.  
  231.  
  232.         SECTION    MUDevInfoBSS,BSS
  233.  
  234. mustores    ds.b    MUDev_SIZEOF
  235.  
  236.  
  237.         END
  238.